﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Mogre.Tests
{
  public partial class OgreForm : Form
  {
    private IOgreControl _ogreControl;

    public OgreForm(IOgreControl ogreControl)
    {
      _ogreControl = ogreControl;
      InitializeComponent();

      Size = new Size(800, 600);
      Disposed += OgreForm_Disposed;
      Resize += OgreForm_Resize;
    }

    public void StartRendering()
    {
      Show();
      while(_ogreControl.RunOneFrame())
        Application.DoEvents();
    }

    private void OgreForm_Resize(object sender, EventArgs e)
    {
      _ogreControl.OgreForm_Resize( sender,  e);
    }

    private void OgreForm_Disposed(object sender, EventArgs e)
    {
      _ogreControl.OgreForm_Disposed( sender,  e);
    }

    public void Init()
    {
      _ogreControl.Init(this.Handle);
    }
  }
}